import QtQuick 2.0
import QtQuick.Controls 2.5

Rectangle{
    id: rectangle
    color: "#EBEBEB"
    height: 60
    signal newFirend()

    Text{
        id:_text
        text: "微信"
        anchors.centerIn: parent
        font.pixelSize: 18
    }

    Button{
        anchors.right: parent.right
        anchors.rightMargin: 20
        anchors.top: _text.top

        height: _text.height
        width: height
        onClicked: parent.newFirend();


        background: Rectangle {

            // 按下的时候，加上灰色，否则透明
            color: parent.down ? "#DDD" : "transparent"

            // 绘制“加号”
            Canvas {
                anchors.fill: parent

                onPaint: { // Context2D
                    var ctx = getContext("2d");
                    var lineBegin = 6
                    ctx.strokeStyle ="#444"
                    ctx.lineWidth = 1.5
                    ctx.ellipse(ctx.lineWidth,ctx.lineWidth,width - ctx.lineWidth*2,height - ctx.lineWidth*2)
                    ctx.moveTo(width/2,lineBegin)
                    ctx.lineTo(width/2,height-lineBegin)
                    ctx.moveTo(lineBegin,height/2)
                    ctx.lineTo(width-lineBegin,height/2)
                    ctx.stroke()

                }
            }
        }

    }

}
